home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / bbs / cit_src_7H21.lha / vorlister.c < prev    next >
C/C++ Source or Header  |  1997-08-19  |  2KB  |  79 lines

  1. /**
  2.  Vortex File Lister Version 1.00
  3. **/
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <libraries/dos.h>
  8. #include <dos.h>
  9. #include "ctdl.h"
  10. #include "vortex.h"
  11. #include <stdlib.h>
  12.  
  13. struct FileInfoBlock *info;
  14. char *filename;
  15. void Process_File(char *name);
  16.  
  17. void main( int argc, char **argv);
  18. void main( int argc, char **argv)
  19.   {
  20.   int error, attr;
  21.   if( argc == 1 )
  22.     {
  23.     filename = "#?";
  24.     info  = (struct FileInfoBlock *)calloc(1,sizeof(struct FileInfoBlock));
  25.     attr = 1;          /* find all files not directories */
  26.     error = dfind(info,filename,attr);  /* get first one*/
  27.     while( error == 0 )
  28.       {
  29.       Process_File(info->fib_FileName);
  30.       error = dnext(info);
  31.       };
  32.     free(info);
  33.     }
  34.   else
  35.     {
  36.     while( argc > 1 )
  37.       {
  38.       argc--;
  39.       Process_File(argv[argc]);
  40.       };
  41.     }
  42.   }
  43.  
  44. void Process_File(char *name)
  45.   {
  46.   ROOM_ENTRY_TYPE rec;
  47.   FILE *ip;
  48.   if( ( ip = fopen(name, "r") ) == NULL )
  49.     {
  50.     printf("Error: cannot open %s\n", name);
  51.     }
  52.   else
  53.     {
  54.     if( fread((void *)&rec, sizeof(ROOM_ENTRY_TYPE), 1, ip) != 1 )
  55.       {
  56.       printf("Error: could not read a record for file %s\n",name);
  57.       }
  58.     else
  59.       {
  60.       int node, nnodes;
  61.       nnodes = rec.index;
  62.       node   = ( nnodes < MAX_VORTEX_SIZE ) ? 0 : rec.next_slot;
  63.       printf("Vortex File: %s Index: %d Next: %d\n", name, rec.index, rec.next_slot );
  64.       printf(" %20s %12s %10s %10s %s\n","Origin", "Src Id", "Date", "Time","Checksum");
  65.       while( nnodes-- )
  66.         {
  67.         printf( "%20s %12s %10s %10s %08.8X\n",
  68.         rec.msg_entry[node].mborig,
  69.         rec.msg_entry[node].mbsrcId,
  70.         rec.msg_entry[node].mbdate,
  71.         rec.msg_entry[node].mbtime,
  72.         rec.msg_entry[node].check_sum);
  73.         node = ( node + 1 ) % MAX_VORTEX_SIZE;
  74.         };
  75.       };
  76.     fclose(ip);
  77.     };
  78.   }
  79.